class Solution(object):
    def maxScoreIndices(self, nums):
        n = len(nums)
        for i in range(1, n):
            nums[i] += nums[i - 1]
        ans = [0] * (n + 1)
        ans[0] = nums[-1]
        ans[n] = n - nums[-1]
        for i in range(1, n):
            ans[i] = i - nums[i - 1] + nums[-1] - nums[i - 1]
        max_val = max(ans)
        out = []
        for index, val in enumerate(ans):
            if val == max_val:
                out.append(index)
        return out